import os
import shutil

lingren_live_streaming_script_folder = '/Users/xuchaosheng/Documents/lingren-live-streaming-script/'
lingren_live_streaming_audio_folder = '/Users/xuchaosheng/Documents/lingren-live-streaming-audio/'
lingren_live_streaming_user_folder = '/Users/xuchaosheng/Documents/lingren-live-streaming-user/'

# 同步回复文件
for product in os.listdir(os.path.join(lingren_live_streaming_user_folder,'config','回复文件')):
    if product.startswith('.'):
        continue
    
    shutil.rmtree(os.path.join(lingren_live_streaming_user_folder,'config','回复文件',product))

for product in os.listdir(os.path.join(lingren_live_streaming_audio_folder,'config','回复文件')):
    if product.startswith('.'):
        continue
    
    if not os.path.exists(os.path.join(lingren_live_streaming_user_folder,'config','回复文件',product)):
        os.mkdir(os.path.join(lingren_live_streaming_user_folder,'config','回复文件',product))

    for file in os.listdir(os.path.join(lingren_live_streaming_audio_folder,'config','回复文件',product)):
        if file.startswith('.'):
            continue

        shutil.copy(os.path.join(lingren_live_streaming_audio_folder,'config','回复文件',product,file),os.path.join(lingren_live_streaming_user_folder,'config','回复文件',product,file))


for platform in os.listdir(os.path.join(lingren_live_streaming_script_folder,'config','指令文件')):
    if platform.startswith('.'):
        continue

    for product in os.listdir(os.path.join(lingren_live_streaming_script_folder,'config','指令文件',platform)):
        if product.startswith('.'):
            continue

        if not os.path.exists(os.path.join(lingren_live_streaming_script_folder,'config','话术脚本',platform)):
            os.mkdir(os.path.join(lingren_live_streaming_script_folder,'config','话术脚本',platform))

        if not os.path.exists(os.path.join(lingren_live_streaming_script_folder,'config','话术脚本',platform,product)):
            os.mkdir(os.path.join(lingren_live_streaming_script_folder,'config','话术脚本',platform,product))

        if not os.path.exists(os.path.join(lingren_live_streaming_script_folder,'config','话术脚本',platform,product,'文本库')):
            os.mkdir(os.path.join(lingren_live_streaming_script_folder,'config','话术脚本',platform,product,'文本库'))

        with open(os.path.join(lingren_live_streaming_script_folder,'config','话术脚本',platform,product,'文本库','.DS_Store'),'w',encoding = 'utf-8') as f:
            pass

        ###############################################################################################################################################

        if not os.path.exists(os.path.join(lingren_live_streaming_audio_folder,'config','话术脚本',platform)):
            os.mkdir(os.path.join(lingren_live_streaming_audio_folder,'config','话术脚本',platform))

        if not os.path.exists(os.path.join(lingren_live_streaming_audio_folder,'config','话术脚本',platform,product)):
            os.mkdir(os.path.join(lingren_live_streaming_audio_folder,'config','话术脚本',platform,product))

        if not os.path.exists(os.path.join(lingren_live_streaming_audio_folder,'config','话术脚本',platform,product,'文本库')):
            os.mkdir(os.path.join(lingren_live_streaming_audio_folder,'config','话术脚本',platform,product,'文本库'))

        with open(os.path.join(lingren_live_streaming_audio_folder,'config','话术脚本',platform,product,'文本库','.DS_Store'),'w',encoding = 'utf-8') as f:
            pass
            
        ###############################################################################################################################################

        if not os.path.exists(os.path.join(lingren_live_streaming_user_folder,'config','话术脚本',platform)):
            os.mkdir(os.path.join(lingren_live_streaming_user_folder,'config','话术脚本',platform))

        if not os.path.exists(os.path.join(lingren_live_streaming_user_folder,'config','话术脚本',platform,product)):
            os.mkdir(os.path.join(lingren_live_streaming_user_folder,'config','话术脚本',platform,product))

        if not os.path.exists(os.path.join(lingren_live_streaming_user_folder,'config','话术脚本',platform,product,'文本库')):
            os.mkdir(os.path.join(lingren_live_streaming_user_folder,'config','话术脚本',platform,product,'文本库'))

        with open(os.path.join(lingren_live_streaming_user_folder,'config','话术脚本',platform,product,'文本库','.DS_Store'),'w',encoding = 'utf-8') as f:
            pass


for platform in os.listdir(os.path.join(lingren_live_streaming_script_folder,'config','话术脚本')):
    if platform == '.DS_Store':
        continue

    if not os.path.exists(os.path.join(lingren_live_streaming_script_folder,'config','指令文件',platform)):
        shutil.rmtree(os.path.join(lingren_live_streaming_script_folder,'config','话术脚本',platform))

    for product in os.listdir(os.path.join(lingren_live_streaming_script_folder,'config','话术脚本',platform)):
        if product == '.DS_Store':
            continue

        if not os.path.exists(os.path.join(lingren_live_streaming_script_folder,'config','指令文件',platform,product)):
            shutil.rmtree(os.path.join(lingren_live_streaming_script_folder,'config','话术脚本',platform,product))

###############################################################################################################################################

for platform in os.listdir(os.path.join(lingren_live_streaming_audio_folder,'config','话术脚本')):
    if platform == '.DS_Store':
        continue

    if not os.path.exists(os.path.join(lingren_live_streaming_script_folder,'config','指令文件',platform)):
        shutil.rmtree(os.path.join(lingren_live_streaming_audio_folder,'config','话术脚本',platform))

    for product in os.listdir(os.path.join(lingren_live_streaming_audio_folder,'config','话术脚本',platform)):
        if product == '.DS_Store':
            continue

        if not os.path.exists(os.path.join(lingren_live_streaming_script_folder,'config','指令文件',platform,product)):
            shutil.rmtree(os.path.join(lingren_live_streaming_audio_folder,'config','话术脚本',platform,product))

###############################################################################################################################################

for platform in os.listdir(os.path.join(lingren_live_streaming_user_folder,'config','话术脚本')):
    if platform == '.DS_Store':
        continue

    if not os.path.exists(os.path.join(lingren_live_streaming_script_folder,'config','指令文件',platform)):
        shutil.rmtree(os.path.join(lingren_live_streaming_user_folder,'config','话术脚本',platform))

    for product in os.listdir(os.path.join(lingren_live_streaming_user_folder,'config','话术脚本',platform)):
        if product == '.DS_Store':
            continue
            
        if not os.path.exists(os.path.join(lingren_live_streaming_script_folder,'config','指令文件',platform,product)):
            shutil.rmtree(os.path.join(lingren_live_streaming_user_folder,'config','话术脚本',platform,product))




